package elementui.notice;

import java.util.Random;
import java.util.UUID;

/**
 * elementui.notice zgw --2020/7/1 10:52 上午
 * author javazgw@gmail.com
 * methods: {
 *       open() {
 *         this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
 *           confirmButtonText: '确定',
 *           cancelButtonText: '取消',
 *           type: 'warning'
 *         }).then(() => {
 *           this.$message({
 *             type: 'success',
 *             message: '删除成功!'
 *           });
 *         }).catch(() => {
 *           this.$message({
 *             type: 'info',
 *             message: '已取消删除'
 *           });
 *         });
 *       }
 *     }
 */
public class MessageBox {
     String uuid = UUID.randomUUID().toString().replaceAll("-","_");
    String type ;

    String confirmbuttonstr;
    String message;
    String title,successmess,cancelmess;
    public MessageBox()
    {

    }


    public static String getDefaultMessageBox()
    {
        String html ="";

        MessageBox mb = new MessageBox();
        mb.setCancelmess("已取消删除");

        mb.setMessage("此操作将永久删除该文件, 是否继续?");
        mb.setSuccessmess("删除成功!");
        mb.setTitle("提示");


        html += mb.getDefaultHtml() +"\n";
        html += mb.getDefaultScript();
        return html;
    }
    public  String getDefaultHtml()
    {
        return "<el-button type=\"text\" @click=\"open_"+uuid+"\">点击打开 Message Box</el-button>";
    }
    public String getDefaultScript()
    {
        return "open_"+uuid+"() {\n" +
                "        this.$confirm('"+getMessage()+"', '"+getTitle()+"', {\n" +
                "          confirmButtonText: '确定',\n" +
                "          cancelButtonText: '取消',\n" +
                "          type: 'warning'\n" +
                "        }).then(() => {\n" +
                "          this.$message({\n" +
                "            type: 'success',\n" +
                "            message: '"+getSuccessmess()+"!'\n" +
                "          });\n" +
                "        }).catch(() => {\n" +
                "          this.$message({\n" +
                "            type: 'info',\n" +
                "            message: '"+getCancelmess()+"'\n" +
                "          });          \n" +
                "        });\n" +
                "      }";
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }


    public String getConfirmbuttonstr() {
        return confirmbuttonstr;
    }

    public void setConfirmbuttonstr(String confirmbuttonstr) {
        this.confirmbuttonstr = confirmbuttonstr;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getSuccessmess() {
        return successmess;
    }

    public void setSuccessmess(String successmess) {
        this.successmess = successmess;
    }

    public String getCancelmess() {
        return cancelmess;
    }

    public void setCancelmess(String cancelmess) {
        this.cancelmess = cancelmess;
    }
}
